<?php
/**
 * 杂项类库
 * @copyright reginx.com
 * $Id: misc.lib.php 97 2012-12-10 09:45:33Z reginx.com@gmail.com $
 */
class misc_lib{
    
    /**
     * 获取导航数据 (非实时)
     *
     * @param unknown_type $parent
     * @param unknown_type $ctype
     * @return unknown
     */
    public static function getnav($parent = 0 ,$ctype = 0){
        $key = 'misc@nav-' . $parent . '-' . $type;
        $ret = $GLOBALS['_CACHE']->get($key , '');
        if(!$ret || IS_DEBUG){
            $ret = core::getobj('nav_tab')->where("parent = {$parent} and ctype = {$ctype}")->order('sort desc , id asc')->getall();
            $ret && $GLOBALS['_CACHE']->set($key , $ret , 0 , '');
        }
        return $ret;
    }
    
    /**
     * 获取misc_tab 中 v字段
     *
     * @param unknown_type $key
     * @return unknown
     */
    public static function get($key , $cache = 1){
        $ret = $GLOBALS['_CACHE']->get($key , '');
        if(!$ret || !$cache){
            $obj = core::getobj('misc_tab');
            $ret = $obj->where("k = '$key'")->get();
            $ret = $ret ? unserialize(base64_decode($ret['v'])) : null;
            $ret && $GLOBALS['_CACHE']->set($key , $v , 0 , '');
        }
        return $ret;
    }
}
?>